# All relevant packages
packages <- c("plyr", "dplyr", "tidyr", "tidyverse", "stargazer", "sandwich", 
              "foreign", "ggmap", "splines", "broom", "data.table", 
              "dotwhisker", "gdata", "stm", "xtable", "foreach")

# Install packages not yet installed
installedPackages <- packages %in% rownames(installed.packages())
if (any(installedPackages == FALSE)) {
  install.packages(packages[!installedPackages])
}

# Load packages
invisible(lapply(packages, library, character.only = TRUE))